﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;


namespace DataAccess
{
   public  class DALFactory
    {
       private DBSourceType dbSrcType;
       private string strConnection;

       public string StrConnection
       {
           get { return strConnection; }
           set { strConnection = value; }
       }
       public DBSourceType DbSrcType
        {
            get { return dbSrcType; }
            set { dbSrcType = value; }
        }

        public DALFactory(DBSourceType sourceType,string strConnectionString) 
        {
            DbSrcType = sourceType;
            StrConnection = strConnectionString;
        }

        public DataAccess<T> GetAccessObj<T>() where T:class 
        {
            switch (DbSrcType)
            {
                case DBSourceType.SQL:
                    return new DataAccess.SQL.SQLAccess<T>(StrConnection);
                case DBSourceType.OLEDB:
                    return new DataAccess.OLEDB.OLEDBAccess<T>(StrConnection);           
                case DBSourceType.ODBC:
                    return new DataAccess.ODBC.ODBCAccess<T>(StrConnection);
                default:
                    throw new Exception("no such source type!");
               
            }
        }

    }
}
